home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / edit / envwrd41.lha / envWRD41 / source / words / tag.a < prev   
Text File  |  1996-10-12  |  5KB  |  151 lines

  1.  
  2.             ;   TAG.ASM
  3.             ;
  4.             ;   Library tag.  This replaces the normal startup code, c.o,
  5.             ;   but still must perform certain startup functions such as
  6.             ;   the clearing of BSS and small-data model setup & auto
  7.             ;   calls.  HOWEVER, we do not include any resident startup
  8.             ;   code meaning you CANNOT compile the shared library -r
  9.             ;   (which doesn't make sense to do anyway).
  10.             ;
  11.             ;   Further, no C startup or exit functions are included
  12.             ;   since this is a library, not a normal program.  Refer
  13.             ;   to the source code LIB/AMIGA/C.A for a fully operational
  14.             ;   startup module.
  15.  
  16. ;Prototype ALibExpunge(), ALibClose(), ALibOpen(), ALibReserved();
  17.  
  18.             section text,code
  19.  
  20.             xref    @LibInit
  21.             xref    @LibOpen
  22.             xref    @LibClose
  23.             xref    @LibExpunge
  24.  
  25.             xref    __BSS_LEN           ; (dlink), length of BSS
  26.             xref    __DATA_BAS          ; (dlink), base of initialized data
  27.             xref    __DATA_LEN          ; (dlink), length of data
  28.  
  29.  
  30.             xdef    _LibId
  31.             xdef    _LibName
  32.  
  33.             xdef    _ALibOpen
  34.             xdef    _ALibClose
  35.             xdef    _ALibExpunge
  36.             xdef    _ALibReserved
  37.  
  38.             clr.l   D0
  39.             rts
  40.  
  41. InitDesc:   dc.w    $4AFC       ;RTC_MATCHWORD
  42.             dc.l    InitDesc    ;Pointer to beginning
  43.             dc.l    EndCode     ;Note sure it matters
  44.             dc.b    0           ;flags (NO RTF_AUTOINIT)
  45.             dc.b    37          ;version
  46.             dc.b    9           ;NT_LIBRARY
  47.             dc.b    0           ;priority (doesn't matter)
  48.             dc.l    _LibName    ;Name of library
  49.             dc.l    _LibId      ;ID string (note CR-LF at end)
  50.             dc.l    Init        ;Pointer to init routine
  51.  
  52. _LibName:   dc.b    'words.api',0
  53. _LibId:     dc.b    'words.api 37.0 (28.8.1996)',13,10,0
  54.             ds.w    0
  55. EndCode:
  56.  
  57. Init:       move.l  A0,-(sp)        ; save arg to Init
  58.  
  59.             movem.l D2-D7/A2-A6,-(sp)   ; blanket save
  60.             move.l  4,A6                ; EXEC base
  61.  
  62.             ;   Not resident, BSS space has been allocated for us
  63.             ;   beyond the specified data, just load the base ptr
  64.  
  65. snotres     lea     __DATA_BAS+32766,A4
  66.             sub.l   A3,A3
  67.  
  68. clrbss
  69.             ;   CLEAR BSS   &-32766(A4) + __DATA_LEN*4
  70.  
  71.             lea     -32766(A4),A0
  72.             move.l  #__DATA_LEN,D0
  73.             asl.l   #2,D0
  74.             add.l   D0,A0
  75.  
  76.             move.l  #__BSS_LEN,D0       ; longwords of bss
  77.             moveq.l #0,D1
  78.             bra     clrent
  79. clrlop      move.l  D1,(A0)+
  80. clrent      dbf     D0,clrlop
  81.             sub.l   #$10000,D0
  82.             bcc     clrlop
  83.  
  84.             jsr     __AutoInit0         ; A6 has SYSBase
  85.             bne     xfail
  86.             jsr     __AutoInit1         ; A6 has SYSBase
  87.             bne     xfail
  88.  
  89.             movem.l (sp)+,D2-D7/A2-A6   ; blanket restore
  90.             move.l  (sp)+,D0            ; retrieve arg to Init to D0
  91.             jmp     @LibInit(pc)
  92.  
  93.             ;   if failure occurs (auto library open failed), return NULL
  94.  
  95. xfail       movem.l (sp)+,D2-D7/A2-A6
  96.             move.l  (sp)+,D0            ; pop/ignore arg
  97.             moveq.l #0,D0
  98.             rts
  99.  
  100.             ;   Assembly tags for other functions, assume a registered
  101.             ;   C entry point
  102.  
  103. _ALibOpen
  104.             move.l  A6,A0
  105.             jmp     @LibOpen(pc)
  106.  
  107. _ALibClose
  108.             move.l  A6,A0
  109.             jsr     @LibClose(pc)
  110.             bra     xend
  111.  
  112. _ALibExpunge
  113.             move.l  A6,A0
  114.             jsr     @LibExpunge(pc)
  115.  
  116. _ALibReserved
  117.             moveq.l #0,D0
  118.             rts
  119.  
  120.             ;   if CLOSE/EXPUNGE returns non-zero, the library is going
  121.             ;   away.
  122.  
  123. xend
  124.             tst.l   D0
  125.             beq     xend2
  126.  
  127.             movem.l D0/A4/A6,-(sp)
  128.             move.l  4.W,A6
  129.             lea     __DATA_BAS+32766,A4
  130.             jsr     __AutoExit1
  131.             jsr     __AutoExit0
  132.             movem.l (sp)+,D0/A4/A6
  133. xend2       rts
  134.  
  135.             ;   These are special DICE sections that merge together special
  136.             ;   code from other object modules and link libraries, the base
  137.             ;   of which is defined here.
  138.  
  139.                 section autoinit0,code
  140. __AutoInit0:
  141.                 section autoinit1,code
  142. __AutoInit1:
  143.                 section autoexit0,code
  144. __AutoExit0:
  145.                 section autoexit1,code
  146. __AutoExit1:
  147.  
  148.  
  149.             END
  150.  
  151.